package com.ll.SchoolSafe.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ll.SchoolSafe.Service.SafetyEducationService;
import com.ll.SchoolSafe.pojo.CommonResult;
import com.ll.SchoolSafe.pojo.Safety;
import com.ll.SchoolSafe.pojo.SafetyTheme;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


    @RestController
    @Api(tags = "安全教育")
    public class SafeEducationController {
        @Autowired
        private SafetyEducationService safetyService;

        /**
         * 获取栏目分类下的所有安全教育信息
         *
         * @return
         */
        @ApiOperation("获取所有栏目")
        @GetMapping("/getSafeEducation/getAllSafetyTheme")
        public CommonResult getSafeEducation() {
            CommonResult safeEducation = safetyService.getSafeEducation();
            return safeEducation;
        }

        @ApiOperation("获取栏目下的所有安全教育信息按时间排序")
        @GetMapping("/getSafeEducation/getAllSafetyByThemeId/{safetyThemeId}")
        public CommonResult getSafetyTheme(@PathVariable Integer safetyThemeId) {
            CommonResult safetyTheme = safetyService.getSafetyTheme(safetyThemeId);
            return safetyTheme;
        }


        @ApiOperation("根据安全教育文章的id获取该文章的详细数据")
        @GetMapping("/getSafeEducation/getSafetyBySafetyId/{safetyId}")
        public CommonResult getAllSafety(@PathVariable Integer safetyId) {
            CommonResult allSafety = safetyService.getAllSafety(safetyId);
            return allSafety;
        }

        @ApiOperation("阅读文章时增加阅读量")
        @PutMapping("/getSafeEducation/addReadNumber/{safetyId}")
        public CommonResult addReadCount(@PathVariable Integer safetyId) {
            safetyService.addReadCount(safetyId);
            return new CommonResult(200, "阅读量增加成功", null);
        }
    }

